/**
 * 
 */
package uit.comstore.model.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * @author XIII
 *
 */
@Entity
@Table(name="Orders")
@SuppressWarnings("serial")
public class Order implements Serializable {

	private Long id;
	private Integer paymentStatus;
	private String deliveryAddress;
	private Date datePurchased;
	private BigDecimal total;
	
	private Customer customer;
	private PaymentMethod paymentMethod;
	private Set<OrderDetail> orderDetail = new HashSet<OrderDetail>();

	@Id
	@GeneratedValue
	@Column(name="OrdersId")
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}

	@Column(name="PaymentStatus")
	public Integer getPaymentStatus() {
		return paymentStatus;
	}
	public void setPaymentStatus(Integer paymentStatus) {
		this.paymentStatus = paymentStatus;
	}

	@Column(name="DeliveryAddress")
	public String getDeliveryAddress() {
		return deliveryAddress;
	}
	public void setDeliveryAddress(String deliveryAddress) {
		this.deliveryAddress = deliveryAddress;
	}

	@Column(name="DatePurchased")
	public Date getDatePurchased() {
		return datePurchased;
	}
	public void setDatePurchased(Date datePurchased) {
		this.datePurchased = datePurchased;
	}

	@Column(name="OrdersTotal")
	public BigDecimal getTotal() {
		return total;
	}
	public void setTotal(BigDecimal total) {
		this.total = total;
	}

	@ManyToOne(cascade=CascadeType.MERGE)
	@JoinColumn(name="CustomersId", referencedColumnName="CustomersId")
	public Customer getCustomer() {
		return customer;
	}
	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
	
	@ManyToOne(cascade=CascadeType.ALL)
	@JoinColumn(name="PaymentMethodsId", referencedColumnName="PaymentMethodsId")
	public PaymentMethod getPaymentMethod() {
		return paymentMethod;
	}
	public void setPaymentMethod(PaymentMethod paymentMethod) {
		this.paymentMethod = paymentMethod;
	}
	
	@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
	@JoinColumn(name="OrdersId", referencedColumnName="OrdersId")
	public Set<OrderDetail> getOrderDetail() {
		return orderDetail;
	}
	public void setOrderDetail(Set<OrderDetail> orderDetail) {
		this.orderDetail = orderDetail;
	}
}
